package util

import (
	"fmt"
	"math"
	"math/rand"
	"time"
)

func init() {
	rand.Seed(time.Now().UnixNano())
}

// RandInt [min, max]
func RandInt(min, max int) int {
	if min > max {
		return min
	}

	return min + rand.Intn(max-min+1)
}

// RoundFloat RoundFloat
func RoundFloat(number float32) int {
	var s = fmt.Sprintf("%0.0f", number)
	return StringToInt(s)
}

// AbsInt AbsInt
func AbsInt(number int) int {
	if number >= 0 {
		return number
	}

	return -number
}

func MaxInt(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func MaxInt64(x, y int64) int64 {
	return int64(math.Max(float64(x), float64(y)))
}

func MinInt(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func MinInt64(x, y int64) int64 {
	return int64(math.Min(float64(x), float64(y)))
}
